const express = require('express');
const router = express.Router()
const userCtrl = require('../controller/user')
const userValidator = require('../validator/user');
const auth = require('../middleware/auth')
// 登录
router.post('/users/login', userValidator.login, userCtrl.login)
// 用户注册
router.post('/users', userValidator.register, userCtrl.register) // 3、通过验证，执行具体控制器
// 获取当前登录用户信息
router.get('/user', auth, userCtrl.getCurrentUser)
// 更新当前登录用户信息
router.put('/user', auth, userCtrl.updateCurrentUser)

module.exports = router